import React from 'react';
import classNames from 'classnames';
import styles from './index.module.less';
import BaseComp from "../Base/BaseComp";
import {CheckCircleOutlined, CloseOutlined, InfoCircleOutlined} from "@ant-design/icons";

export default class Result extends BaseComp {
    mainRender(context) {
        const {
            className,
            type,
            title,
            description,
            extra,
            actions,
            children,
            ...restProps
        } = this.props;
        const iconMap = {
            error: <CloseOutlined className={styles.error} theme="filled"/>,
            success: <CheckCircleOutlined className={styles.success}  theme="filled"/>,
            info: <InfoCircleOutlined className={styles.info} theme="filled"/>,
        };
        const clsString = classNames(styles.result, className);
        return (
            <div className={clsString} {...restProps}>
                <div className={styles.icon}>{iconMap[type]}</div>
                <div className={styles.title}>{title}</div>
                {description && <div className={styles.description}>{description}</div>}
                {extra && <div className={styles.extra}>{extra}</div>}
                {actions && <div className={styles.actions}>{actions}</div>}
                {children}
            </div>
        )
    }
}